<template>
    <div>
        <table class="wq text-center" border="0" cellpadding="0" cellspacing="1">
            <tr class="t_list_caption">
                <td v-for="(item,index) in 6" :key="index"><label class="flexbox"><input type="radio" name="radiotype" :value="index" v-model="continuousData.radioopt" @change="radioChange"></label></td>
            </tr>
            <tr class="t_td_text">
                <td>任选二</td>
                <td>选二连组</td>
                <td>任选三</td>
                <td>选三前组</td>
                <td>任选四</td>
                <td>任选五</td>
            </tr>
            <tr class="t_td_text">
                <td class="colorRed bolds">{{ratedata['连码:任选二:$fn']}}</td>
                <td class="colorRed bolds">{{ratedata['连码:选二连组:$fn']}}</td>
                <td class="colorRed bolds">{{ratedata['连码:任选三:$fn']}}</td>
                <td class="colorRed bolds">{{ratedata['连码:选三前组:$fn']}}</td>
                <td class="colorRed bolds">{{ratedata['连码:任选四:$fn']}}</td>
                <td class="colorRed bolds">{{ratedata['连码:任选五:$fn']}}</td>
            </tr>
        </table>
        <table class="wq text-center" border="0" cellpadding="0" cellspacing="1">
            <tr class="t_list_caption">
                <td colspan="8">号码</td>
            </tr>
            <tr class="t_td_text">
                <td><span class="No_gd01"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['01']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['01']"></label></td>
                <td><span class="No_gd06"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['06']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['06']"></label></td>
                <td><span class="No_gd11"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['11']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['11']"></label></td>
                <td><span class="No_gd16"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['16']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['16']"></label></td>
            </tr>
            <tr class="t_td_text">
                <td><span class="No_gd02"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['02']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['02']"></label></td>
                <td><span class="No_gd07"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['07']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['07']"></label></td>
                <td><span class="No_gd12"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['12']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['12']"></label></td>
                <td><span class="No_gd17"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['17']" @change="checkboxChange" :disabled="continuousData.betArr.length > (continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['17']"></label></td>
            </tr>
            <tr class="t_td_text">
                <td><span class="No_gd03"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['03']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['03']"></label></td>
                <td><span class="No_gd08"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['08']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['08']"></label></td>
                <td><span class="No_gd13"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['13']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['13']"></label></td>
                <td><span class="No_gd18"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['18']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['18']"></label></td>
            </tr>
            <tr class="t_td_text">
                <td><span class="No_gd04"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['04']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['04']"></label></td>
                <td><span class="No_gd09"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['09']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['09']"></label></td>
                <td><span class="No_gd14"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['14']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['14']"></label></td>
                <td><span class="No_gd19"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['19']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['19']"></label></td>
            </tr>
            <tr class="t_td_text">
                <td><span class="No_gd05"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['05']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['05']"></label></td>
                <td><span class="No_gd10"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['10']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['10']"></label></td>
                <td><span class="No_gd15"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['15']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['15']"></label></td>
                <td><span class="No_gd20"></span></td>
                <td><label class="flexbox"><input type="checkbox" name="checkboxtype" v-model="moneydata['20']" @change="checkboxChange" :disabled="continuousData.betArr.length >(continuousData.radioopt == 0 || continuousData.radioopt == 1 || continuousData.radioopt == 2 || continuousData.radioopt == 3 ? 6 : 4 ) && !moneydata['20']"></label></td>
            </tr>
            
        </table>

    </div>
    
    
</template>
<style scoped>
    input[name='radiotype'],input[name='checkboxtype']{
        margin: 3px auto;
    }
</style>

<script>
    var timer = null;
    import axios from 'axios'
    import {lotterytype} from '../../../../assets/js/lotterytype.js'
    export default {
        name: "GdklsfContinuous",
        props: {  //普通类型：String、Number、Boolean、Null    引用类型： Array、Object
            betmoney: {   //   下注金额
                type: String,
                required: true
            },
            openBet: {  //开奖  可下注
                type: Boolean,
                required: true
            },
            ninetime: {  //90s
                type: Number,
                required: true
            },
        },
        data(){
            return{
                ratedata: {},  //实时赔率
                params: {},  //菜单
                moneydata: {},  //是否下注
                continuousData: {
                    betArr: [],  //下注数组
                    radioopt: 0,  //当前类别
                    betnowtype: 0,  //当前类别 赔率
                },
                
            }
        },
        methods: {
            init(){

                var _this = this;

                this.params = lotterytype.apiParams(this.$route.query.id,this.$route.query.levelid);

                if(window.localStorage.Authorization){
                    
                    _this.$httpGet('/api/game/listRate/'+ _this.params.nowlottery + '/' + _this.params.levellottery +'oa18').then(response => {
                        
                        if(response.status == 200){
                            _this.ratedata = response.data.rates;
                            _this.continuousData.betnowtype = response.data.rates['连码:任选二:$fn'];
                            _this.$emit('contBetFun',_this.continuousData);

                            if(response.data.need){
                                _this.$httpPost('/api/setting/rateItem/'+ _this.params.nowlottery + '/' + _this.params.levellottery +'oa18').then(response => {
                                
                                    if(response.status == 200){
                                        
                                    }

                                });
                            }
                        }

                    });
                }
            },
            inits(){

                var _this = this;

                this.params = lotterytype.apiParams(this.$route.query.id,this.$route.query.levelid);

                if(window.localStorage.Authorization){
                    
                    if (timer) {
                        clearInterval(timer);
                        timer = null;
                    }

                    _this.$httpGet('/api/game/listRate/'+ _this.params.nowlottery + '/' + _this.params.levellottery +'oa18').then(response => {
                        
                        if(response.status == 200){
                            _this.ratedata = response.data.rates;
                            _this.continuousData.betnowtype = response.data.rates['连码:任选二:$fn'];
                            _this.$emit('contBetFun',_this.continuousData);

                            if(response.data.need){
                                _this.$httpPost('/api/setting/rateItem/'+ _this.params.nowlottery + '/' + _this.params.levellottery +'oa18').then(response => {
                                
                                    if(response.status == 200){
                                        
                                    }

                                });
                            }

                            timer = setInterval(() => {
                                _this.inits();
                            }, 10 * 1000)
                        }

                    });
                }
            },
            //切换类别
            radioChange(){

                if(this.continuousData.radioopt == 0){  //任选二
                    this.continuousData.betnowtype = this.ratedata['连码:任选二:$fn'];
                }else if(this.continuousData.radioopt == 1){  //选二连组
                    this.continuousData.betnowtype = this.ratedata['连码:选二连组:$fn'];
                }else if(this.continuousData.radioopt == 2){  //任选三
                    this.continuousData.betnowtype = this.ratedata['连码:任选三:$fn'];
                }else if(this.continuousData.radioopt == 3){  //选三前组
                    this.continuousData.betnowtype = this.ratedata['连码:选三前组:$fn'];
                }else if(this.continuousData.radioopt == 4){  //任选四
                    this.continuousData.betnowtype = this.ratedata['连码:任选四:$fn'];
                }else if(this.continuousData.radioopt == 5){  //任选五
                    this.continuousData.betnowtype = this.ratedata['连码:任选五:$fn'];
                }

                this.moneydata = {};
                this.continuousData.betArr = [];
                console.log(this.moneydata);
                this.$emit('contBetFun',this.continuousData);

            },
            //
            checkboxChange(item){

                this.continuousData.betArr = [];

                for (var index in this.moneydata){

                    if(this.moneydata[index]){
                        this.continuousData.betArr.push(index);
                    }

                }

                this.$emit('contBetFun',this.continuousData);

            },
            
        },
        mounted(){
            this.inits();
        },
        beforeDestroy(){
            clearInterval(timer);
        },
        watch :{
            openBet: function(now,old){
                console.log(now,old);
                this.init();
            },
            ninetime: function(now,old){
                console.log('------------90s  刷新');
                //90s  刷新数据
                this.init();
            },
        },
    }
</script>
